home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / demos / 8 / readme.doc / graphic.doc < prev    next >
Encoding:
Text File  |  1985-06-09  |  8.1 KB  |  293 lines

  1.             4xFORTH Level 1 Graphics
  2.  
  3.  
  4.  
  5. Overview
  6. --------
  7.  
  8.     Although the Level 1 system does not support the full GEM
  9.     interface for the Atari computer, it does support a number
  10.     of graphics functions.  Some of these are to routines which
  11.     lie at the core of the GEM system, called "line A" graphics,
  12.     while others are more complex calls built using the "line A"
  13.     routines.
  14.  
  15.     
  16. Screen Coordinates
  17. ------------------
  18.  
  19.     The Atari screen pixel numbering system begins with x=0, y=0 at
  20.     the upper left corner of the screen.  All calls requiring x and
  21.     y positions REQUIRE absolute pixel numbers based in this coordi-
  22.     nate system.  If you wish to provide routines which will run on
  23.     all display devices, regardless of their height and width in
  24.     absolute pixels, we suggest you add routines above these primi-
  25.     tives which scale a "virtual coordinate" to the physical one
  26.     and then call the primitive.  This might be done in the following
  27.     way:
  28.  
  29.         V RYMAX                \ real screen y max     
  30.         V RXMAX                \ real screen x max
  31.     
  32.         V VYMIN                \ virtual window y min
  33.         V VXMIN                \ virtual window x min
  34.         V VYMAX                \ virtual window y max
  35.         V VXMAX                \ virtual window x max
  36.  
  37.         ( remember:  V is a legal contraction of VARIABLE )
  38.  
  39.     : SCALER  (  <virtual x> <virtual y>  ---  <screen x> <screen y> )
  40.         VYMIN @ -              \ calc y distance from
  41.                           \   virtual origin
  42.         RYMAX @   VYMAX @  VYMIN @ -  W*/ \ scale y value
  43.         >R                      \ save new Y coordinate
  44.         VXMIN @ -              \ calc x distance from
  45.                           \   virtual origin
  46.         RXMAX @   VXMAX @  VXMIN @ -  W*/ \ scale x value
  47.         R> ;                   \ restore y
  48.  
  49.         \    convert virtual x,y to screen x,y
  50.         \    assumes that virtual coordinate system
  51.         \    is not larger that 0 to 65000
  52.  
  53.  
  54.  
  55. Variables in the Graphics system
  56. --------------------------------
  57.  
  58.     The following are variables used in the graphics system:
  59.  
  60.  
  61.     VARIABLE CUR.X                    GRAPHICS
  62.  
  63.     This 16 bit variable contains the current absolute x
  64.     screen pixel value at which the logical screen painting
  65.     beam is located.  It is initialized to zero after the
  66.     execution of ORIGIN.  The contents of this variable are
  67.     kept current by the graphics routines.  W@ and W! operators
  68.     should be used in accessing this variable.
  69.  
  70.  
  71.  
  72.     VARIABLE CUR.Y                    GRAPHICS
  73.  
  74.     This 16 bit variable contains the current absolute y
  75.     screen pixel value at which the logical screen painting
  76.     beam is located.  It is initialized to zero after the
  77.     execution of ORIGIN.  The contents of this variable are
  78.     kept current by the graphics routines.    W@ and W! operators
  79.     should be used in accessing this variable.
  80.  
  81.  
  82.     VARIABLE PAT_PNTR                GRAPHICS
  83.  
  84.     PAT_PNTR will contain a 32b address value which is used by
  85.     several routines to point to a 16 (16b) word array to be used
  86.     as the pattern control for filled areas.  There are really
  87.     four arrays, one after another, which are used to control the
  88.     fill in each of the ST's color planes.  If the variable
  89.     MULTI_FILL is set to 0, only the first of these arrays is
  90.     actually used for control.  The user may provide his own
  91.     pattern, or he may use one of the 18 provided with 4xFORTH.
  92.     See PATTERNS, and note the fills used in the demo program.
  93.  
  94.  
  95.     VARIABLE MULTI_FILL                GRAPHICS
  96.  
  97.     This 16 bit variable is a flag which is used in those
  98.     operations which control area filling.  If it is set to
  99.     0, the pattern fill will use only the first of the 16 w
  100.     x 16b arrays pointed to by PAT_PNTR for control of the
  101.     fill.  Any other value will cause the correct number
  102.     of 16 bit arrays to be used depending on the number of
  103.     color planes currently being used by the display.  That
  104.     is controlled by the resolution setting of the system.
  105.  
  106.  
  107. Arrays in the Graphics System
  108. -----------------------------
  109.  
  110.     ARRAY  FULL.PATTERN                GRAPHICS
  111.  
  112.     FULL.PATTERN is an array whose address is placed in PAT_PNTR
  113.     when solid fills are desired.
  114.  
  115.  
  116.     ARRAY  PATTERNS                    GRAPHICS
  117.  
  118.     The array PATTERNS contains the addresses of 18 fill patterns,
  119.     named P1 thru P18, which are provided with the 4xFORTH system.
  120.     The contents of the patterns may be seen in the demo.  Their
  121.     addresses are provided in this array for use with loop "I counter
  122.     selection.
  123.  
  124.  
  125. Graphics Primitive Routines
  126. ---------------------------
  127.  
  128.     COLON    CLEAR                    GRAPHICS
  129.  
  130.     Clear the screen.
  131.  
  132.  
  133.     COLON    ORIGIN                    GRAPHICS
  134.  
  135.     Set the position of the logical screen painting beam at
  136.     X=0,Y=0.  This should be executed prior to the execution of
  137.     any routine which moves the beam or paints any lines on the
  138.     screen.
  139.  
  140.  
  141.     COLON    CLIP.WINDOW                GRAPHICS
  142.  
  143.         ( <x1><y1> <x2><y2> ---  ) 
  144.  
  145.     CLIP.WINDOW uses the specified values to establish the size
  146.     and the location of a rectangle which will be displayed for
  147.     those routines which allow clipping, and the calls to which
  148.     indicate that clipping should be applied.
  149.  
  150.  
  151.     CODE    DRAW.LINE                GRAPHICS
  152.  
  153.         ( <x1><y1> <x2><y2> <mode> ---   )
  154.  
  155.     DRAW.LINE draws a line from X1,Y1 to X2,Y2.  The arguments
  156.     are absolute screen coordinates.  The mode value means:
  157.  
  158.         0 = replace mode
  159.         1 = transparent mode
  160.         2 = XOR mode
  161.         3 = inverse transparent mode
  162.  
  163.     DRAW.LINE updates the variables CUR.X and CUR.Y so that the
  164.     programmer may query them for the current position of the 
  165.     logical beam.  DRAW.LINE is the basis of the Tektronix
  166.     4010 line instructions MOV, DRW, RMOV, and RDRW.
  167.  
  168.  
  169.     CODE RECTANGLE                    GRAPHICS
  170.  
  171.         ( <x1><y1> <x2><y2> <clip flg><mode> ---  ) 
  172.  
  173.     RECTANGLE paints a rectangle whose TOP left corner is x1,y1
  174.     and lower right corner is x2,y2.  If the clip flag is 0, no
  175.     clipping window is applied.  If it is set to -1, clipping is
  176.     done to the window set using the CLIP.WINDOW definition.  The
  177.     mode flag meaning is:
  178.  
  179.             0 = replace mode
  180.             1 = transparent mode
  181.             2 = XOR mode
  182.             3 = inverse transparent mode
  183.  
  184.     Fill is controlled by the PAT_PNTR value and the MULTI_FILL
  185.     flag.
  186.  
  187.  
  188. Basic TEK4010 Drawing routines
  189. ------------------------------
  190.  
  191.     COLON    MOV                    GRAPHICS
  192.  
  193.         ( <x> <y>  ---   )
  194.  
  195.     MOV from the current position to the specified X,Y position
  196.     with the logical beam OFF.  This emulates the 4010 command
  197.     MOVE.
  198.  
  199.  
  200.     COLON    DRW                    GRAPHICS
  201.  
  202.         ( <x> <y>  ---   ) 
  203.  
  204.     DRW causes a line to be drawn from the current position to
  205.     the X,Y position specified in the call.  DRW emulates the 
  206.     TEK4010 command DRAW.
  207.  
  208.  
  209.     COLON    RMOV                    GRAPHICS
  210.  
  211.         ( <x> <y>  ---   ) 
  212.  
  213.     RMOV moves the beam to a new position which is the sum of
  214.     the current position and the relative pixel values given
  215.     in the call.  The relative nature of this command makes
  216.     it ideal for construction of figures whose size or position
  217.     is likely to be changed.
  218.  
  219.  
  220.     COLON RDRW                    GRAPHICS
  221.  
  222.         ( <x> <y>  ---   ) 
  223.  
  224.     RDRW paints a line from the current position of the beam to
  225.     a new position which is calculated from the original beam
  226.     position plus the relative pixel values given in the call.
  227.     The relative nature of this command makes it ideal for the 
  228.     construction of figures whose size or position is likely to
  229.     be changed.
  230.  
  231.  
  232. Color Specification
  233. -------------------
  234.  
  235.     COLON    RED                    GRAPHICS
  236.  
  237.     Set the foreground color to red.
  238.  
  239.  
  240.     COLON    GREEN                    GRAPHICS
  241.  
  242.     Set the forground color to green.
  243.  
  244.  
  245.     COLON    BLACK                    GRAPHICS
  246.  
  247.     Set the foreground color to black.
  248.  
  249.  
  250.     COLON    WHITE                    GRAPHICS
  251.  
  252.     Set the foreground color to white.
  253.  
  254.  
  255. Simple Figures
  256. --------------
  257.  
  258.     COLON    BOX                    GRAPHICS
  259.  
  260.         ( <x size> <y size> ---  ) 
  261.  
  262.     Draw a rectangle using the current x,y position as the
  263.     upper left corner.  Use the  specified values as the
  264.     size of the box in absolute screen coordinates.  Leave
  265.     the beam at the upper left corner of the box.
  266.  
  267.  
  268.     COLON    TRI.UP                    GRAPHICS
  269.  
  270.         ( <x size> ---   )
  271.  
  272.     Paint a triangle with the point up around the current position
  273.     of the cursor.  Use the specified value as the size in the 
  274.     x direction.  Scale the y direction so that the triangle is
  275.     properly shaped.  Return the beam to its position prior to
  276.     the call.
  277.  
  278.  
  279.     COLON    TRI.DN                    GRAPHICS
  280.  
  281.         ( <x size> ---  )
  282.  
  283.     Do the same function as TRI.UP except paint a triangle with the
  284.     point down.
  285.  
  286.  
  287.  
  288.     COLON    DIAMOND                    GRAPHICS
  289.  
  290.         ( <x size> ---   )
  291.  
  292.     Do the same function as TRI.UP except paint a diamond.
  293. ə